package zelix.hack.hacks;

import zelix.hack.Hack;
import zelix.hack.HackCategory;
import zelix.value.Mode;
import zelix.value.ModeValue;
import zelix.value.NumberValue;
import zelix.managers.HackManager;
import zelix.utils.MoveUtils;
import zelix.utils.PlayerControllerUtils;
import zelix.utils.TimerUtils;
import zelix.utils.Utils;
import zelix.utils.hooks.visual.ChatUtils;
import zelix.utils.Wrapper;

public class LongJump extends Hack {
	Hack h = HackManager.getHack("Blink");
	TimerUtils timer = new TimerUtils();
	ModeValue mode;
	NumberValue distance;
	NumberValue blinktime;
	NumberValue y;

	public LongJump() {
		super("LongJump", HackCategory.MOVEMENT);
		this.mode = new ModeValue("Mode", new Mode("Simple", false), new Mode("Blink", true),new Mode("HYT", false));
		this.blinktime = new NumberValue("BlinkTime", 500D, 0D, 2000D);
		this.distance=new NumberValue("Distance", 4D, 2D, 8D);
		this.y=new NumberValue("MotionY", 0.4D, 0D, 2D);
		this.addValue(mode, blinktime,distance,y);

	}

	@Override
	public String getDescription() {
		return "Jump further";
	}

	@Override
	public void onEnable() {
		Utils.nullCheck();
		if (mode.getMode("Simple").isToggled()) {
			Jump();
		} else if (mode.getMode("Blink").isToggled()) {
			h.onEnable();
			h.setToggled(true);
			Jump();

		}else if(mode.getMode("HYT").isToggled()) {
			h.onEnable();
			h.setToggled(true);
			JumpHYT();
			if(timer.hasReached(blinktime.getValue().floatValue())) {
				ChatUtils.message("OK");
			this.onDisable();
			timer.reset();
			}
		}

		// this.setToggled(false);
		super.onEnable();
	}

	@Override
	public void onDisable() {
		h.onDisable();
		h.setToggled(false);
		super.onDisable();
	}

	public void Jump() {
		if (PlayerControllerUtils.isMoving()) {

			MoveUtils.strafeHYT(distance.getValue().floatValue());
			Wrapper.INSTANCE.player().motionY = y.getValue().floatValue();

			MoveUtils.strafeHYT(distance.getValue().floatValue());
		} else {
			Wrapper.INSTANCE.player().motionX = Wrapper.INSTANCE.player().motionZ = 0D;
		}
	}
	public void JumpHYT() {
		if (PlayerControllerUtils.isMoving()) {

			MoveUtils.strafeHYT(distance.getValue().floatValue());
			Wrapper.INSTANCE.player().motionY = y.getValue().floatValue();

			MoveUtils.strafeHYT(distance.getValue().floatValue());
		} else {
			Wrapper.INSTANCE.player().motionX = Wrapper.INSTANCE.player().motionZ = 0D;
		}
	}
}
